 package cn.myframe.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface CommonDao {

	/**
	 * 
	 * @param tableName 表名
	 * @param param 条件参数名
	 * @param id  参数值
	 * @return
	 */
	@Select("select count(*) from ${tableName} where ${param}= #{id}")
	int checkCount(@Param("tableName")String tableName, @Param("param")String param,@Param("id") String id);

	/**
	 * 根据ID查询出相关的对象信息
	 * @param tableName 表名
	 * @param param 参数名
	 * @param id 参数值
	 * @return
	 */
	@Select("select * from ${tableName} where ${param} = #{id}")
	Map<String,Object> queryRelated(@Param("tableName")String tableName, @Param("param")String param,@Param("id") String id);

	/**
	 * 查询频道传输流ID和节目ID的唯一性(新增)
	 * @param tableName
	 * @param param1
	 * @param id1
	 * @param param2
	 * @param id2
	 * @param object 
	 * @return
	 */
	@Select("select count(*) from ${tableName} where ${param1} = #{id1} and ${param2} = #{id2}")
	int checkUniqueOfProAndTrans(@Param("tableName")String tableName,@Param("param1") String param1,
			@Param("id1")String id1,@Param("param2")String param2,@Param("id2") String id2);

	/**
	 * 查询频道传输流ID和节目ID的唯一性(修改)
	 * @param tableName
	 * @param param1
	 * @param id1
	 * @param param2
	 * @param id2
	 * @param object 
	 * @return
	 */
	@Select("select count(*) from ${tableName} where ${param1} = #{id1} and ${param2} = #{id2} and id != #{id3}")
	int checkUniqueOfProAndTrans1(@Param("tableName")String tableName,@Param("param1") String param1,
			@Param("id1")String id1,@Param("param2")String param2,@Param("id2") String id2 ,@Param("id3") Integer id3);


	/**
	 * 查询前置广告内容
	 * @param tableName
	 * @param param
	 * @param id
	 * @return
	 */
	@Select("select * from ${tableName} where ${param} = #{id}")
	List<Map<String ,Object>> queryPreAd (@Param("tableName")String tableName ,@Param("param") String param 
			,@Param("id") String id);

	
}
